if(CONFIG_BT_ENABLED)

    set(COMPONENT_SRCS "bt.c")
    set(COMPONENT_ADD_INCLUDEDIRS include)

    if(CONFIG_BLUEDROID_ENABLED)

        list(APPEND COMPONENT_PRIV_INCLUDEDIRS
            bluedroid/bta/include
            bluedroid/bta/ar/include
            bluedroid/bta/av/include
            bluedroid/bta/dm/include
            bluedroid/bta/gatt/include
            bluedroid/bta/hf_client/include
            bluedroid/bta/hh/include
            bluedroid/bta/jv/include
            bluedroid/bta/sdp/include
            bluedroid/bta/sys/include
            bluedroid/device/include
            bluedroid/hci/include
            bluedroid/osi/include
            bluedroid/external/sbc/decoder/include
            bluedroid/external/sbc/encoder/include
            bluedroid/btc/profile/esp/blufi/include
            bluedroid/btc/profile/esp/include
            bluedroid/btc/profile/std/a2dp/include
            bluedroid/btc/profile/std/include
            bluedroid/btc/include
            bluedroid/stack/btm/include
            bluedroid/stack/gap/include
            bluedroid/stack/gatt/include
            bluedroid/stack/l2cap/include
            bluedroid/stack/sdp/include
            bluedroid/stack/smp/include
            bluedroid/stack/avct/include
            bluedroid/stack/avrc/include
            bluedroid/stack/avdt/include
            bluedroid/stack/a2dp/include
            bluedroid/stack/rfcomm/include
            bluedroid/stack/include
            bluedroid/common/include)

        list(APPEND COMPONENT_ADD_INCLUDEDIRS bluedroid/api/include/api)

        list(APPEND COMPONENT_SRCS "bluedroid/api/esp_a2dp_api.c"
                   "bluedroid/api/esp_avrc_api.c"
                   "bluedroid/api/esp_blufi_api.c"
                   "bluedroid/api/esp_bt_device.c"
                   "bluedroid/api/esp_bt_main.c"
                   "bluedroid/api/esp_gap_ble_api.c"
                   "bluedroid/api/esp_gap_bt_api.c"
                   "bluedroid/api/esp_gatt_common_api.c"
                   "bluedroid/api/esp_gattc_api.c"
                   "bluedroid/api/esp_gatts_api.c"
                   "bluedroid/api/esp_hf_client_api.c"
                   "bluedroid/api/esp_spp_api.c"
                   "bluedroid/bta/ar/bta_ar.c"
                   "bluedroid/bta/av/bta_av_aact.c"
                   "bluedroid/bta/av/bta_av_act.c"
                   "bluedroid/bta/av/bta_av_api.c"
                   "bluedroid/bta/av/bta_av_cfg.c"
                   "bluedroid/bta/av/bta_av_ci.c"
                   "bluedroid/bta/av/bta_av_main.c"
                   "bluedroid/bta/av/bta_av_sbc.c"
                   "bluedroid/bta/av/bta_av_ssm.c"
                   "bluedroid/bta/dm/bta_dm_act.c"
                   "bluedroid/bta/dm/bta_dm_api.c"
                   "bluedroid/bta/dm/bta_dm_cfg.c"
                   "bluedroid/bta/dm/bta_dm_ci.c"
                   "bluedroid/bta/dm/bta_dm_co.c"
                   "bluedroid/bta/dm/bta_dm_main.c"
                   "bluedroid/bta/dm/bta_dm_pm.c"
                   "bluedroid/bta/dm/bta_dm_sco.c"
                   "bluedroid/bta/gatt/bta_gatt_common.c"
                   "bluedroid/bta/gatt/bta_gattc_act.c"
                   "bluedroid/bta/gatt/bta_gattc_api.c"
                   "bluedroid/bta/gatt/bta_gattc_cache.c"
                   "bluedroid/bta/gatt/bta_gattc_ci.c"
                   "bluedroid/bta/gatt/bta_gattc_co.c"
                   "bluedroid/bta/gatt/bta_gattc_main.c"
                   "bluedroid/bta/gatt/bta_gattc_utils.c"
                   "bluedroid/bta/gatt/bta_gatts_act.c"
                   "bluedroid/bta/gatt/bta_gatts_api.c"
                   "bluedroid/bta/gatt/bta_gatts_co.c"
                   "bluedroid/bta/gatt/bta_gatts_main.c"
                   "bluedroid/bta/gatt/bta_gatts_utils.c"
                   "bluedroid/bta/hh/bta_hh_act.c"
                   "bluedroid/bta/hh/bta_hh_api.c"
                   "bluedroid/bta/hh/bta_hh_cfg.c"
                   "bluedroid/bta/hh/bta_hh_le.c"
                   "bluedroid/bta/hh/bta_hh_main.c"
                   "bluedroid/bta/hh/bta_hh_utils.c"
                   "bluedroid/bta/jv/bta_jv_act.c"
                   "bluedroid/bta/jv/bta_jv_api.c"
                   "bluedroid/bta/jv/bta_jv_cfg.c"
                   "bluedroid/bta/jv/bta_jv_main.c"
                   "bluedroid/bta/sdp/bta_sdp.c"
                   "bluedroid/bta/sdp/bta_sdp_act.c"
                   "bluedroid/bta/sdp/bta_sdp_api.c"
                   "bluedroid/bta/sdp/bta_sdp_cfg.c"
                   "bluedroid/bta/sys/bta_sys_conn.c"
                   "bluedroid/bta/sys/bta_sys_main.c"
                   "bluedroid/bta/sys/utl.c"
                   "bluedroid/btc/core/btc_alarm.c"
                   "bluedroid/btc/core/btc_ble_storage.c"
                   "bluedroid/btc/core/btc_config.c"
                   "bluedroid/btc/core/btc_dev.c"
                   "bluedroid/btc/core/btc_dm.c"
                   "bluedroid/btc/core/btc_main.c"
                   "bluedroid/btc/core/btc_manage.c"
                   "bluedroid/btc/core/btc_profile_queue.c"
                   "bluedroid/btc/core/btc_sec.c"
                   "bluedroid/btc/core/btc_sm.c"
                   "bluedroid/btc/core/btc_storage.c"
                   "bluedroid/btc/core/btc_task.c"
                   "bluedroid/btc/core/btc_util.c"
                   "bluedroid/btc/profile/esp/blufi/blufi_prf.c"
                   "bluedroid/btc/profile/esp/blufi/blufi_protocol.c"
                   "bluedroid/btc/profile/std/a2dp/bta_av_co.c"
                   "bluedroid/btc/profile/std/a2dp/btc_a2dp.c"
                   "bluedroid/btc/profile/std/a2dp/btc_a2dp_control.c"
                   "bluedroid/btc/profile/std/a2dp/btc_a2dp_sink.c"
                   "bluedroid/btc/profile/std/a2dp/btc_a2dp_source.c"
                   "bluedroid/btc/profile/std/a2dp/btc_av.c"
                   "bluedroid/btc/profile/std/avrc/btc_avrc.c"
                   "bluedroid/btc/profile/std/gap/btc_gap_ble.c"
                   "bluedroid/btc/profile/std/gap/btc_gap_bt.c"
                   "bluedroid/btc/profile/std/gatt/btc_gatt_common.c"
                   "bluedroid/btc/profile/std/gatt/btc_gatt_util.c"
                   "bluedroid/btc/profile/std/gatt/btc_gattc.c"
                   "bluedroid/btc/profile/std/gatt/btc_gatts.c"
                   "bluedroid/btc/profile/std/spp/btc_spp.c"
                   "bluedroid/device/bdaddr.c"
                   "bluedroid/device/controller.c"
                   "bluedroid/device/interop.c"
                   "bluedroid/external/sbc/decoder/srce/alloc.c"
                   "bluedroid/external/sbc/decoder/srce/bitalloc-sbc.c"
                   "bluedroid/external/sbc/decoder/srce/bitalloc.c"
                   "bluedroid/external/sbc/decoder/srce/bitstream-decode.c"
                   "bluedroid/external/sbc/decoder/srce/decoder-oina.c"
                   "bluedroid/external/sbc/decoder/srce/decoder-private.c"
                   "bluedroid/external/sbc/decoder/srce/decoder-sbc.c"
                   "bluedroid/external/sbc/decoder/srce/dequant.c"
                   "bluedroid/external/sbc/decoder/srce/framing-sbc.c"
                   "bluedroid/external/sbc/decoder/srce/framing.c"
                   "bluedroid/external/sbc/decoder/srce/oi_codec_version.c"
                   "bluedroid/external/sbc/decoder/srce/synthesis-8-generated.c"
                   "bluedroid/external/sbc/decoder/srce/synthesis-dct8.c"
                   "bluedroid/external/sbc/decoder/srce/synthesis-sbc.c"
                   "bluedroid/external/sbc/encoder/srce/sbc_analysis.c"
                   "bluedroid/external/sbc/encoder/srce/sbc_dct.c"
                   "bluedroid/external/sbc/encoder/srce/sbc_dct_coeffs.c"
                   "bluedroid/external/sbc/encoder/srce/sbc_enc_bit_alloc_mono.c"
                   "bluedroid/external/sbc/encoder/srce/sbc_enc_bit_alloc_ste.c"
                   "bluedroid/external/sbc/encoder/srce/sbc_enc_coeffs.c"
                   "bluedroid/external/sbc/encoder/srce/sbc_encoder.c"
                   "bluedroid/external/sbc/encoder/srce/sbc_packing.c"
                   "bluedroid/hci/hci_audio.c"
                   "bluedroid/hci/hci_hal_h4.c"
                   "bluedroid/hci/hci_layer.c"
                   "bluedroid/hci/hci_packet_factory.c"
                   "bluedroid/hci/hci_packet_parser.c"
                   "bluedroid/hci/packet_fragmenter.c"
                   "bluedroid/main/bte_init.c"
                   "bluedroid/main/bte_main.c"
                   "bluedroid/osi/alarm.c"
                   "bluedroid/osi/allocator.c"
                   "bluedroid/osi/buffer.c"
                   "bluedroid/osi/config.c"
                   "bluedroid/osi/fixed_queue.c"
                   "bluedroid/osi/future.c"
                   "bluedroid/osi/hash_functions.c"
                   "bluedroid/osi/hash_map.c"
                   "bluedroid/osi/list.c"
                   "bluedroid/osi/mutex.c"
                   "bluedroid/osi/osi.c"
                   "bluedroid/osi/semaphore.c"
                   "bluedroid/stack/a2dp/a2d_api.c"
                   "bluedroid/stack/a2dp/a2d_sbc.c"
                   "bluedroid/stack/avct/avct_api.c"
                   "bluedroid/stack/avct/avct_ccb.c"
                   "bluedroid/stack/avct/avct_l2c.c"
                   "bluedroid/stack/avct/avct_lcb.c"
                   "bluedroid/stack/avct/avct_lcb_act.c"
                   "bluedroid/stack/avdt/avdt_ad.c"
                   "bluedroid/stack/avdt/avdt_api.c"
                   "bluedroid/stack/avdt/avdt_ccb.c"
                   "bluedroid/stack/avdt/avdt_ccb_act.c"
                   "bluedroid/stack/avdt/avdt_l2c.c"
                   "bluedroid/stack/avdt/avdt_msg.c"
                   "bluedroid/stack/avdt/avdt_scb.c"
                   "bluedroid/stack/avdt/avdt_scb_act.c"
                   "bluedroid/stack/avrc/avrc_api.c"
                   "bluedroid/stack/avrc/avrc_bld_ct.c"
                   "bluedroid/stack/avrc/avrc_bld_tg.c"
                   "bluedroid/stack/avrc/avrc_opt.c"
                   "bluedroid/stack/avrc/avrc_pars_ct.c"
                   "bluedroid/stack/avrc/avrc_pars_tg.c"
                   "bluedroid/stack/avrc/avrc_sdp.c"
                   "bluedroid/stack/avrc/avrc_utils.c"
                   "bluedroid/stack/btm/btm_acl.c"
                   "bluedroid/stack/btm/btm_ble.c"
                   "bluedroid/stack/btm/btm_ble_addr.c"
                   "bluedroid/stack/btm/btm_ble_adv_filter.c"
                   "bluedroid/stack/btm/btm_ble_batchscan.c"
                   "bluedroid/stack/btm/btm_ble_bgconn.c"
                   "bluedroid/stack/btm/btm_ble_cont_energy.c"
                   "bluedroid/stack/btm/btm_ble_gap.c"
                   "bluedroid/stack/btm/btm_ble_multi_adv.c"
                   "bluedroid/stack/btm/btm_ble_privacy.c"
                   "bluedroid/stack/btm/btm_dev.c"
                   "bluedroid/stack/btm/btm_devctl.c"
                   "bluedroid/stack/btm/btm_inq.c"
                   "bluedroid/stack/btm/btm_main.c"
                   "bluedroid/stack/btm/btm_pm.c"
                   "bluedroid/stack/btm/btm_sco.c"
                   "bluedroid/stack/btm/btm_sec.c"
                   "bluedroid/stack/btu/btu_hcif.c"
                   "bluedroid/stack/btu/btu_init.c"
                   "bluedroid/stack/btu/btu_task.c"
                   "bluedroid/stack/gap/gap_api.c"
                   "bluedroid/stack/gap/gap_ble.c"
                   "bluedroid/stack/gap/gap_conn.c"
                   "bluedroid/stack/gap/gap_utils.c"
                   "bluedroid/stack/gatt/att_protocol.c"
                   "bluedroid/stack/gatt/gatt_api.c"
                   "bluedroid/stack/gatt/gatt_attr.c"
                   "bluedroid/stack/gatt/gatt_auth.c"
                   "bluedroid/stack/gatt/gatt_cl.c"
                   "bluedroid/stack/gatt/gatt_db.c"
                   "bluedroid/stack/gatt/gatt_main.c"
                   "bluedroid/stack/gatt/gatt_sr.c"
                   "bluedroid/stack/gatt/gatt_utils.c"
                   "bluedroid/stack/hcic/hciblecmds.c"
                   "bluedroid/stack/hcic/hcicmds.c"
                   "bluedroid/stack/l2cap/l2c_api.c"
                   "bluedroid/stack/l2cap/l2c_ble.c"
                   "bluedroid/stack/l2cap/l2c_csm.c"
                   "bluedroid/stack/l2cap/l2c_fcr.c"
                   "bluedroid/stack/l2cap/l2c_link.c"
                   "bluedroid/stack/l2cap/l2c_main.c"
                   "bluedroid/stack/l2cap/l2c_ucd.c"
                   "bluedroid/stack/l2cap/l2c_utils.c"
                   "bluedroid/stack/l2cap/l2cap_client.c"
                   "bluedroid/stack/rfcomm/port_api.c"
                   "bluedroid/stack/rfcomm/port_rfc.c"
                   "bluedroid/stack/rfcomm/port_utils.c"
                   "bluedroid/stack/rfcomm/rfc_l2cap_if.c"
                   "bluedroid/stack/rfcomm/rfc_mx_fsm.c"
                   "bluedroid/stack/rfcomm/rfc_port_fsm.c"
                   "bluedroid/stack/rfcomm/rfc_port_if.c"
                   "bluedroid/stack/rfcomm/rfc_ts_frames.c"
                   "bluedroid/stack/rfcomm/rfc_utils.c"
                   "bluedroid/stack/sdp/sdp_api.c"
                   "bluedroid/stack/sdp/sdp_db.c"
                   "bluedroid/stack/sdp/sdp_discovery.c"
                   "bluedroid/stack/sdp/sdp_main.c"
                   "bluedroid/stack/sdp/sdp_server.c"
                   "bluedroid/stack/sdp/sdp_utils.c"
                   "bluedroid/stack/smp/aes.c"
                   "bluedroid/stack/smp/p_256_curvepara.c"
                   "bluedroid/stack/smp/p_256_ecc_pp.c"
                   "bluedroid/stack/smp/p_256_multprecision.c"
                   "bluedroid/stack/smp/smp_act.c"
                   "bluedroid/stack/smp/smp_api.c"
                   "bluedroid/stack/smp/smp_br_main.c"
                   "bluedroid/stack/smp/smp_cmac.c"
                   "bluedroid/stack/smp/smp_keys.c"
                   "bluedroid/stack/smp/smp_l2c.c"
                   "bluedroid/stack/smp/smp_main.c"
                   "bluedroid/stack/smp/smp_utils.c")
    endif()
endif()

# requirements can't depend on config
set(COMPONENT_PRIV_REQUIRES nvs_flash)

register_component()

if(CONFIG_BT_ENABLED)
    if(GCC_NOT_5_2_0)
        component_compile_options(-Wno-implicit-fallthrough -Wno-unused-const-variable)
    endif()

    target_link_libraries(${COMPONENT_TARGET} "-L${CMAKE_CURRENT_LIST_DIR}/lib")
    target_link_libraries(${COMPONENT_TARGET} btdm_app)
endif()
